]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/network: Rename DeviceCategory and base on device type
authorFlorian Müllner <fmuellner@gnome.org>
Mon, 1 Aug 2022 14:19:43 +0000 (16:19 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sun, 7 Aug 2022 20:41:09 +0000 (22:41 +0200)
Right now DeviceCategory is a small section wrapper that shows
a summary instead of its content if it contains too many items.

It will eventually eventually turn into the base class for
network device quick toggles. Who would have thought that
when it was added for the "there's a computer with 32 ethernet
cards" fringe case?!

For now, give it a more appropriate name and use device types
instead of our made-up categories, now that the two map neatly.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2406>

js/ui/status/network.js

index 8b08dd56bedec3cf90dd1c17a35bde1e91707177..71c16d748d915e4c5cb851b3a4d6bb0977044683 100644 (file)
@@ -1509,11 +1509,11 @@ var NMVpnSection = class extends NMConnectionSection {
     }
 };
 
-var DeviceCategory = class extends PopupMenu.PopupMenuSection {
-    constructor(category) {
+var NMDeviceSection = class extends PopupMenu.PopupMenuSection {
+    constructor(deviceType) {
         super();
 
-        this._category = category;
+        this._deviceType = deviceType;
 
         this.devices = [];
 
@@ -1541,33 +1541,33 @@ var DeviceCategory = class extends PopupMenu.PopupMenuSection {
     }
 
     _getSummaryIcon() {
-        switch (this._category) {
-        case NMConnectionCategory.WIRED:
+        switch (this._deviceType) {
+        case NM.DeviceType.ETHERNET:
             return 'network-wired-symbolic';
-        case NMConnectionCategory.WIRELESS:
-        case NMConnectionCategory.BLUETOOTH:
-        case NMConnectionCategory.WWAN:
+        case NM.DeviceType.WIFI:
+        case NM.DeviceType.BT:
+        case NM.DeviceType.MODEM:
             return 'network-wireless-symbolic';
         }
         return '';
     }
 
     _getSummaryLabel(nDevices) {
-        switch (this._category) {
-        case NMConnectionCategory.WIRED:
+        switch (this._deviceType) {
+        case NM.DeviceType.ETHERNET:
             return ngettext("%s Wired Connection",
                             "%s Wired Connections",
                             nDevices).format(nDevices);
-        case NMConnectionCategory.WIRELESS:
+        case NM.DeviceType.WIFI:
             return ngettext("%s Wi-Fi Connection",
                             "%s Wi-Fi Connections",
                             nDevices).format(nDevices);
-        case NMConnectionCategory.BLUETOOTH:
+        case NM.DeviceType.BT:
             return ngettext(
                 '%s Bluetooth Connection',
                 '%s Bluetooth Connections',
                 nDevices).format(nDevices);
-        case NMConnectionCategory.WWAN:
+        case NM.DeviceType.MODEM:
             return ngettext("%s Modem Connection",
                             "%s Modem Connections",
                             nDevices).format(nDevices);
@@ -1618,14 +1618,14 @@ class Indicator extends PanelMenu.SystemIndicator {
         this._nmDevices = [];
         this._deviceSections = new Map();
 
-        const categories = [
-            NMConnectionCategory.WIRED,
-            NMConnectionCategory.WIRELESS,
-            NMConnectionCategory.BLUETOOTH,
-            NMConnectionCategory.WWAN,
+        const sections = [
+            [NMConnectionCategory.WIRED, NM.DeviceType.ETHERNET],
+            [NMConnectionCategory.WIRELESS, NM.DeviceType.WIFI],
+            [NMConnectionCategory.BLUETOOTH, NM.DeviceType.BT],
+            [NMConnectionCategory.WWAN, NM.DeviceType.MODEM],
         ];
-        for (let category of categories) {
-            this._deviceSections.set(category, new DeviceCategory(category));
+        for (const [category, deviceType] of sections) {
+            this._deviceSections.set(category, new NMDeviceSection(deviceType));
             this.menu.addMenuItem(this._deviceSections.get(category));
         }